package cn.fl.fgi.controller;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.fgi.api.dto.FgiGuarRateDTO;
import cn.fl.fgi.service.IFgiGuarRateService;
import cn.fl.fgi.transform.FgiGuarRateVOTransform;
import cn.fl.fgi.vo.FgiGuarRateVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.preloan.IGetInsParamApiService;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.splrate.transform.ParseTempFileRecVOTransform;
import cn.fl.splrate.vo.ParseTempFileRecVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.common.MagicNumReplaceEnum;
import fl.spl.facade.framework.enums.splrate.BasicDataRelOpBizTypCdEnum;
import fl.spl.facade.framework.enums.splrate.FileOpRelStsCdEnum;
import fl.spl.facade.lnkcomp.constant.LnkCompFlowConstant;
import fl.spl.facade.splrate.condition.ParseTempFileRecQC;
import fl.spl.facade.splrate.dto.ParseTempFileRecDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 费率配置表 控制层
 */
@Controller
@RequestMapping("/fgi/fgiguarrate")
public class FgiGuarRateController extends BaseController {

    @Autowired
    private IGetInsParamApiService getInsParamApiService ;

    @Autowired
    private IFgiGuarRateService fgiGuarRateService;

    @Autowired
    private IFriBaseInfoService friBaseInfoService;

    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("fgi/fgiGuarRate/fgiGuarRateList");
        BaseLogUtils.newWebLogger("加载列表页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();

        List<KeyValueVO> busSourceTypeMap = this.fgiGuarRateService.getBusSourceTypeMap();
        view.addObject("busTypeList", busSourceTypeMap);

        return view;
    }

    /**
     * 到新增修改页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("fgi/fgiGuarRate/fgiGuarRateAdd");

        String guaranteeType = request.getParameter("guaranteeType");
        view.addObject("guaranteeType", guaranteeType);

        List<KeyValueVO> busSourceTypeMap = this.fgiGuarRateService.getBusSourceTypeMap();
        view.addObject("busTypeJson", JSON.toJSONString(busSourceTypeMap));

        return view;
    }

    /**
     * 到修改页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {

        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("fgi/fgiGuarRate/fgiGuarRateModify");
        view.addObject("id", id);
        return view;
    }

    /**
     * 到详情页面
     */
    @RequestMapping(value = "/toDetailPage.do", method = {RequestMethod.GET})
    public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {

        String programNo = request.getParameter("programNo");
        ModelAndView view = new ModelAndView("fgi/fgiGuarRate/fgiGuarRateDetail");
        view.addObject("programNo", programNo);

        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String orgNm = request.getParameter("orgNm");
        String busType = request.getParameter("busType");
        String overdueBeginDay = request.getParameter("overdueBeginDay");
        String overdueEndDay = request.getParameter("overdueEndDay");
        String orgPayBegin = request.getParameter("orgPayBegin");
        String orgPayEnd = request.getParameter("orgPayEnd");
        String repBegin = request.getParameter("repBegin");
        String repEnd = request.getParameter("repEnd");
        String confStatus = request.getParameter("confStatus");

        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        FgiGuarRateDTO qc = new FgiGuarRateDTO();
        if (StringUtils.isNotEmpty(orgNm)) {
            qc.setOrgNm(orgNm);
        }
        if (StringUtils.isNotEmpty(busType)) {
            qc.setBusType(busType);
        }
        if (StringUtils.isNotEmpty(overdueBeginDay) && StringUtils.isNotEmpty(overdueBeginDay)) {
            qc.setOverdueBeginDay(Integer.parseInt(overdueBeginDay));
            qc.setOverdueEndDay(Integer.parseInt(overdueEndDay));
        }
        if (StringUtils.isNotEmpty(orgPayBegin) && StringUtils.isNotEmpty(orgPayEnd)) {
            qc.setOrgPayBegin(DateUtils.formatStringToDate(orgPayBegin, DateUtils.YYYY_MM_DD));
            qc.setOrgPayEnd(DateUtils.formatStringToDate(orgPayEnd, DateUtils.YYYY_MM_DD));
        }
        if (StringUtils.isNotEmpty(repBegin) && StringUtils.isNotEmpty(repEnd)) {
            qc.setRepBegin(DateUtils.formatStringToDate(repBegin, DateUtils.YYYY_MM_DD));
            qc.setRepEnd(DateUtils.formatStringToDate(repEnd, DateUtils.YYYY_MM_DD));
        }
        if (StringUtils.isNotEmpty(confStatus)) {
            qc.setConfStatus(Integer.parseInt(confStatus));
        }

        page.setCondition(qc);
        Pager pager = null;
        try {
            pager = this.fgiGuarRateService.searchListPage(page);
        } catch (IllegalAccessException e) {
            BaseLogUtils.newWebLogger("查询异常").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        }
        ListPageVO<FgiGuarRateVO> listPage = null;
        if (null != pager) {
            List<FgiGuarRateVO> voList = (List<FgiGuarRateVO>) pager.getResultList();
            listPage = new ListPageVO<>(voList, pager.getTotalCount());
        } else {
            listPage = new ListPageVO<>(new ArrayList(), BaseConstant.IS_YESNO_NO);
        }
        BaseLogUtils.newWebLogger("加载列表页面").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPage", JSON.toJSONString(listPage))
                .info();
        return listPage;
    }

    /**
     * 初始化金融机构列表
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/initFriBaseInfoList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initFriBaseInfoList(HttpServletRequest request, HttpServletResponse response) {
        String fundRasInsNm = request.getParameter("fundRasInsNm");// 融资机构名称
        String insSts = request.getParameter("insSts");// 融资机构状态
        String insUseCd = request.getParameter("insUseCd"); // 机构用途

        String condition = request.getParameter("condition");
        String value = "";
        if (StringUtils.isNotBlank(condition)) {
            String con = condition.substring(1, condition.length() - 1);
            if (StringUtils.isNotBlank(con)) {
                net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(con);
                value = (String) fromObject.get("value");
            }
        }

        FriBaseInfoQueryCondition qc = new FriBaseInfoQueryCondition();
        if (StringUtils.isNotEmpty(fundRasInsNm)) {
            qc.setFundRasInsNm(fundRasInsNm);
        }
        if (StringUtils.isNotEmpty(insSts)) {
            qc.setInsSts(insSts);
        }
        if (StringUtils.isNotEmpty(insUseCd)) {
            qc.setInsUseCd(insUseCd);
        }
        if (StringUtils.isNotEmpty(value)) {
            qc.setFundRasInsNm(value.trim());
        }
        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());

        List<FriBaseInfoVO> friBaseInfoVOS = this.friBaseInfoService.searchList(qc);

        ListPageVO<FriBaseInfoVO> listPage = new ListPageVO<FriBaseInfoVO>(friBaseInfoVOS, 0);

        BaseLogUtils.newWebLogger("返回页面数据.DATA:" + JSONObject.toJSONString(friBaseInfoVOS)).setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setWarning(false)
                .info();
        return listPage;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
        List<FgiGuarRateVO> entityList ;
        try {
            entityList = this.getRequestParam(request);
            for (FgiGuarRateVO vo : entityList) {
                vo.setConfStatus(BaseConstant.IS_YESNO_YES);
                vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                vo.setCrtTm(new Date());
            }
            boolean b = this.fgiGuarRateService.batchAdd(entityList);
            if (!b) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("添加失败");
                return result;
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("新增数据失败").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.newWebLogger("新增数据异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        }

        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String id = request.getParameter("id");
        String name = request.getParameter("name");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("数据不存在!");
            return result;
        }
        FgiGuarRateVO entity = null;
        try {
            entity = new FgiGuarRateVO();
            entity.setId(Long.valueOf(id));
            //entity.setName(name);
            //TODO ADD PARAM
            boolean success = this.fgiGuarRateService.modify(entity);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("修改失败!");
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeById.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }
        try {
            this.fgiGuarRateService.removeById(Long.valueOf(id));
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 作废数据
     */
    @RequestMapping(value = "/beInvalid.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO beInvalid(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        String ids= request.getParameter("ids");

        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "作废成功!");
        if (StringUtils.isEmpty(id) && StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }

        try {
            List<Long> idList;
            if (StringUtils.isNotEmpty(ids)) {
                String[] split = ids.split(";");
                idList = new ArrayList<>(split.length);
                for (String s : split) {
                    idList.add(Long.parseLong(s));
                }
                if (StringUtils.isNotEmpty(id)) {
                    idList.add(Long.parseLong(id));
                }
            } else {
                idList = Collections.singletonList(Long.parseLong(id));
            }

            this.fgiGuarRateService.beInvalid(idList);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("作废配置错误").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.newWebLogger("作废配置异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        }

        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }

        try {
            FgiGuarRateVO vo = this.fgiGuarRateService.selectById(Long.valueOf(id));
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在!");
            }
            result.setData(vo);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 根据方案编号查询
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getByProgramNo.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getByProgramNo(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String programNo = request.getParameter("programNo");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
        if (StringUtils.isEmpty(programNo)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("方案编号不能为空!");
            return result;
        }

        try {
            FgiGuarRateVO vo = this.fgiGuarRateService.selectByProgramNo(programNo);
            if(StringUtils.isNotEmpty(vo.getGuarTypCd()) && 2 == vo.getGuarTypCd()){
                vo.setGuarTypCdNm("计算费率");
            }else{
                vo.setGuarTypCdNm("配置费率");
            }
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在!");
            }
            result.setData(vo);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("根据方案编号查询错误").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.newWebLogger("根据方案编号查询异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(BaseExceptionConstant.COMMON_0002_NAME);
        }

        return result;
    }

    private List<FgiGuarRateVO> getRequestParam(HttpServletRequest request) throws BaseException {
        String orgNms = request.getParameter("orgNms");//机构名称
        String busType = request.getParameter("busType");//业务
        //String prjType = request.getParameter("prjType");//项目类型
        String orgPayBegin = request.getParameter("orgPayBegin");//机构放款日期
        String orgPayEnd = request.getParameter("orgPayEnd");//机构放款日期
        String overdueBeginDay = request.getParameter("overdueBeginDay");//逾期天数
        String overdueEndDay = request.getParameter("overdueEndDay");//逾期天数
        String repBegin = request.getParameter("repBegin");//上报时间
        String repEnd = request.getParameter("repEnd");//上报时间
        String repRate = request.getParameter("repRate");//费率
        String enableBegin = request.getParameter("enableBegin");//有效期
        String enableEnd = request.getParameter("enableEnd");//有效期
        String guaranteeType = request.getParameter("guaranteeType");//担保类型
        String guarTypCd = request.getParameter("guarTypCd");

        if (StringUtils.isEmpty(orgNms)) {
            throw new BaseException("机构名称不能为空");
        }
        if (StringUtils.isEmpty(busType)) {
            throw new BaseException("业务不能为空");
        }
        if (StringUtils.isEmpty(guaranteeType)) {
            throw new BaseException("担保类型不能为空");
        }
        if (StringUtils.isEmpty(repRate) && BaseConstant.IS_YESNO_YES_STR.equals(guarTypCd)) {
            throw new BaseException("费率不能为空");
        }

        List<FgiGuarRateVO> list = new ArrayList<>();

        FgiGuarRateVO vo ;

        List<FriBaseInfoVO> friBaseInfoVOS = JSON.parseArray(orgNms, FriBaseInfoVO.class);
        String[] busTypes = busType.split(";");

        for (FriBaseInfoVO nm : friBaseInfoVOS) {
            for (String type : busTypes) {
                vo = new FgiGuarRateVO();
                vo.setOrgId(nm.getId());
                vo.setOrgNm(nm.getFundRasInsNm());
                vo.setBusType(type);
                list.add(vo);
            }
        }

        for (FgiGuarRateVO fgiGuarRateVO : list) {
            fgiGuarRateVO.setGuaranteeType(Integer.parseInt(guaranteeType));
            if (BaseConstant.IS_YESNO_YES_STR.equals(guaranteeType)) {
                if (StringUtils.isNotEmpty(orgPayBegin) && StringUtils.isNotEmpty(orgPayEnd)) {
                    fgiGuarRateVO.setOrgPayBegin(DateUtils.formatStringToDate(orgPayBegin, DateUtils.YYYY_MM_DD));
                    fgiGuarRateVO.setOrgPayEnd(DateUtils.formatStringToDate(orgPayEnd, DateUtils.YYYY_MM_DD));
                }
            } else {
                if (StringUtils.isNotEmpty(overdueBeginDay) && StringUtils.isNotEmpty(overdueEndDay)) {
                    fgiGuarRateVO.setOverdueBeginDay(Integer.parseInt(overdueBeginDay));
                    fgiGuarRateVO.setOverdueEndDay(Integer.parseInt(overdueEndDay));
                }
            }
            if (StringUtils.isNotEmpty(repBegin) && StringUtils.isNotEmpty(repEnd)) {
                fgiGuarRateVO.setRepBegin(DateUtils.formatStringToDate(repBegin, DateUtils.YYYY_MM_DD));
                fgiGuarRateVO.setRepEnd(DateUtils.formatStringToDate(repEnd, DateUtils.YYYY_MM_DD));
            }
            if(StringUtils.isNotEmpty(repRate)) {
                fgiGuarRateVO.setRepRate(Double.parseDouble(repRate));
            }
            if(StringUtils.isNotEmpty(guarTypCd)){
                fgiGuarRateVO.setGuarTypCd(Integer.valueOf(guarTypCd));
            }
            if (StringUtils.isNotEmpty(enableBegin) && StringUtils.isNotEmpty(enableEnd)) {
                fgiGuarRateVO.setEnableBegin(DateUtils.formatStringToDate(enableBegin, DateUtils.YYYY_MM_DD));
                fgiGuarRateVO.setEnableEnd(DateUtils.formatStringToDate(enableEnd, DateUtils.YYYY_MM_DD));
            }
        }

        return list;
    }
}

